package com.class3;
import java.util.Scanner;

import org.openqa.selenium.*;
import web.GetMsg;
import web.WebKeyword;
import org.openqa.selenium.chrome.ChromeDriver;

import java.util.Scanner;

public class Shoping {
    public static void main(String[] args) throws InterruptedException {
        GetMsg msg=new GetMsg();
        msg.openBrowser("chrome");
        Thread.sleep(3000);
       msg.visitPage("http://www.testingedu.com.cn:8000\n");
      msg.clickButton("//*[text()='注册']");
      Thread.sleep(2000);
      msg.clickButton("//*[text()='邮箱注册']");
      msg.sendKeys("//input[@id='username']","1361051227@qq.com");
      msg.sendKeys("//input[@id='verify_code2']","kmgh");
      msg.sendKeys("//input[@id='password']","msg1-12345");
        msg.sendKeys("//input[@id='password2']","msg1-12345");
        msg.sendKeys("//input[@name='invite']","18213315131");

        msg.clickButton("//*[text()='同意协议并注册']");

          Thread.sleep(5000);
        msg.clickButton("//*/div/a[text()='手机']");
        //跳转到第二个页面
        msg.jumpPage();
        Thread.sleep(4000);
        msg.clickButton("//div[@class='xs_img']/a/img[contains(@data-original,'79')]");
        //点击立即购买
        msg.clickButton("//*[text()='立即购买']");
        msg.sendKeys("//div/input[@name='consignee']","上海市浦东新区川沙新镇");
        msg.sendKeys("//div/input[@name='mobile']","0556-2461877");
        msg.selectItems("//select[@id='province']",3);
        Thread.sleep(5000);
        msg.clickButton("//select[@id='city']");
        msg.selectItems("//select[@id='city']","936");
        Thread.sleep(3000);
        msg.clickButton("//select[@id='district']");
        msg.selectItems("//select[@id='district']","937");
        msg.sendKeys("//input[@name='address']","门牌号地址");
        msg.sendKeys("//input[@name='zipcode']","246600");
        msg.clickButton("//a[@id='address_submit']");
        Thread.sleep(4000);
        msg.clickButton("//button[@class='checkout-submit']");
        Thread.sleep(4000);
        msg.clickButton("//*[text()='确认支付方式']");
/*购物
*/

      Shoping sp=new Shoping();
      sp.shoppingPage();





    }
    public void shoppingPage() throws InterruptedException {
      GetMsg msg=new GetMsg();
      msg.openBrowser("chrome");
      Thread.sleep(3000);
      msg.visitPage("http://www.testingedu.com.cn:8000/Home/Goods/goodsInfo/id/79.html");
      msg.clickButton("//*[@id='join_cart']");
      msg.assertEleAttr("//*[@id='join_cart']","加入购物车","加入购物车");
      msg.clickButton("//*[@id='layui-layer-shade2']");
   Thread.sleep(4000);
   msg.clickButton("//*[text()='去结算']");
    }
}
